<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>放大</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        img{
            vertical-align: middle;
        }
        .smallbox{
            border:1px solid #eee;
            width: 450px;
            position: relative;
        }
        .bigbox{
            border:1px solid #eee;
            width: 540px;
            height: 540px;
            position:absolute;
            left:452px;
            top:0;
            overflow: hidden;
            display: none;
        }
        .smallbox .floatbox{
            width: 300px;
            height: 300px;
            background: rgba(0,0,0,.2);
            position: absolute;
            left: 0;
            top: 0;
            display: none;
        }
        .bigbox img{
            position:absolute;
        }
        #expand{
            width: auto;
            float: left;
            position: relative;
            background: red;
            margin: 20px 0px;
        }
    </style>
</head>
<body>
    <div id="expand">
        <div class="smallbox" id="smallbox">
            <img src="simg.jpg" alt="">
            <div class="floatbox"></div>
        </div>
        <div class="bigbox" id="bigbox">
            <img src="bimg.jpg" alt="">
        </div>
    </div>
    <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
        <!-- // <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> -->
    <script src="jquery.js"></script>
    <!-- // <script src="dom.js"></script> -->
    <!--
    <script>
        var smallbox=document.getElementById("smallbox");
        var floatbox=smallbox.children[1];
        var bigbox=document.getElementById("bigbox");
        var Img=bigbox.children[0];
        smallbox.onmouseenter=function(){
            floatbox.style.display="block";
            bigbox.style.display="block";
        }
        smallbox.onmouseleave=function(){
            floatbox.style.display="none";
            bigbox.style.display="none";
        }
        smallbox.onmousemove=function(event){
            var e=event||window.event;
            var left=e.clientX-smallbox.offsetLeft-floatbox.offsetWidth/2;
            var top=e.clientY-smallbox.offsetTop-floatbox.offsetHeight/2;
            if(left<0){
                left=0
            }else if(left>smallbox.offsetWidth-floatbox.offsetWidth){
                left=smallbox.offsetWidth-floatbox.offsetWidth;
            }
            if(top<0){
                top=0
            }else if(top>smallbox.offsetHeight-floatbox.offsetHeight){
                top=smallbox.offsetHeight-floatbox.offsetHeight;
            }
            floatbox.style.left=left+"px";
            floatbox.style.top=top+"px";
            Img.style.left=-left/smallbox.offsetWidth*Img.offsetWidth+"px";
            Img.style.top=-top/smallbox.offsetHeight*Img.offsetHeight+"px";
            

        }
    </script>
    -->
</body>
</html>